//
//  HomeTableViewCell.m
//  DemoV2
//
//  Created by 董一龙 on 2022/6/25.
//

#import "HomeTableViewCell.h"
#import "../../Common.h"

@implementation HomeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        CGFloat height = self.contentView.frame.size.height;
        
        // Image
        [self.contentView addSubview:({
            self.leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, height - 20, height - 20)];
            // self.leftImageView.backgroundColor = [UIColor whiteColor];
            self.leftImageView.contentMode = UIViewContentModeScaleToFill;
            self.leftImageView;
        })];
        
        // Title
        [self.contentView addSubview:({
            self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 15, 80, height - 30)];
//            [self.titleLabel sizeToFit]; // 使用sizeToFit会导致文字消失，没有查明原因
//            self.titleLabel.backgroundColor = [UIColor cyanColor];
            self.titleLabel.font = [UIFont systemFontOfSize:18];
            self.titleLabel.textColor = [UIColor blackColor];
            self.titleLabel;
        })];
        
        // EntryImage
        [self.contentView addSubview:({
            self.entryImageView = [[UIImageView alloc] initWithFrame:CGRectMake(360, 15, 20, 20)];
            self.entryImageView.image = kGetImage(@"jinru.png");
            // self.entryImageView.backgroundColor = [UIColor whiteColor];
            self.entryImageView.contentMode = UIViewContentModeScaleToFill;
            self.entryImageView;
        })];
        
    }
    return self;
}

- (void)layoutTableViewCell{
    [self.titleLabel sizeToFit];
}
@end
